package com.example.myapplication.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.fragment.app.Fragment;

import com.example.myapplication.MyApp;
import com.example.myapplication.R;
import com.google.gson.Gson;
import com.jeremyliao.liveeventbus.LiveEventBus;

import java.util.ArrayList;


public class HomeFragment extends Fragment {


    private AppCompatTextView     mainTextView;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        mainTextView = view.findViewById(R.id.mainTextView);


        mainTextView.setOnClickListener(view1 -> {
            ArrayList<TestBena> arrayList = new ArrayList<TestBena>();
            TestBena testBena = new TestBena();
            testBena.setName("张三");
            testBena.setAge("18");
            testBena.setOther("12312313");
            testBena.setName("张三");
            testBena.setAge("18");
            testBena.setOther("12312313");
            testBena.setName("张三");
            testBena.setAge("18");
            testBena.setOther("12312313");
            testBena.setName("张三");
            testBena.setAge("18");
            testBena.setOther("12312313");
            arrayList.add(testBena);
            MyApp.get().getEditor().putString("test_data",new Gson().toJson(arrayList));
            MyApp.get().getEditor().apply();
        });

        return view;
    }








/*
    @Override
    public void onResume() {
        super.onResume();
        Log.d("TAGS", "fragment onresume 方法");
    }
*/
}
